Process Synchronization


Q1.

Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P. What does the code achieve?
GateOverflow

Q2.

Procedures P1 and P2 have a producer-consumer relationship, communicating by the use of a set of shared buffers.P1 : repeat Obtain an empty buffer Fill it Return a full buffer forever P2: repeat Obtain a full buffer Empty it Return an empty buffer forever Increasing the number of buffers is likely to do which of the following? I. Increase the rate at which requests are satisfied (throughput) II. Decrease the likelihood of deadlock III. Increase the ease of achieving a correct implementation
GateOverflow

Q3.

In multi-programmed systems, it is advantageous if some programs such as editors and compilers can be shared by several users. Which of the following must be true of multi-programmed systems in order that a single copy of a program can be shared by several users? I. The program is a macro II. The program is recursive III. The program is reentrant
GateOverflow

Q4.

Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100. The process are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y-X is __________.
GateOverflow

Q5.

At a particular time the value of counting semaphore is 10. It will become 7 after:
GateOverflow

Q6.

Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S) increments S. During an execution, 20 P(S) operations and 12V(S) operations are issued in some order. The largest initial value of S for which at least one P(S) operation will remain blocked is ________.
GateOverflow

Q7.

At a particular time of computation the value of a counting semaphore is 7. Then 20 P operations and x V operations were completed on this semaphore. If the new value of semaphore is 5, x will be
GateOverflow

Q8.

Choose the correct alternatives (more than one may be correct) and write the corresponding letters only:At a particular time of computation, the value of a counting semaphore is 7. Then 20 P operations and 15 V operations were completed on this semaphore. The resulting value of the semaphore is :
GateOverflow

Q9.

Consider the following threads, T_1, T_2, \text{ and }T_3 executing on a single processor, synchronized using three binary semaphore variables, S_1, S_2, \text{ and }S_3, operated upon using standard wait() and signal(). The threads can be context switched in any order and at any time.Which initialization of the semaphores would print the sequence BCABCABCA ...?
GateOverflow

Q10.

Consider the following pseudocode, where Sis a semaphore initialized to 5 in line #2 and counter is a shared variable initialized to 0 in line #1. Assume that the increment operation in line #7 is not atomic.1. int counter =0; 2. Semaphore S= init(5); 3. void parop(void) 4. { 5. wait(S); 6. wait(S); 7. counter++; 8. signal(S); 9. signal(S); 10. } If five threads execute the function parop concurrently, which of the following program behavior(s) is/are possible?[MSQ]
GateOverflow